VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Jeevan 
   Caption         =   "Jeevan Vaisya Agrotech"
   ClientHeight    =   8850
   ClientLeft      =   165
   ClientTop       =   555
   ClientWidth     =   13425
   LinkTopic       =   "Form1"
   ScaleHeight     =   8850
   ScaleWidth      =   13425
   Begin VB.PictureBox Picture1 
      Height          =   1215
      Left            =   120
      ScaleHeight     =   1155
      ScaleWidth      =   5115
      TabIndex        =   57
      Top             =   7440
      Width           =   5175
      Begin VB.CommandButton Command1 
         Caption         =   "Print"
         Height          =   375
         Left            =   1920
         TabIndex        =   60
         Top             =   600
         Width           =   1095
      End
      Begin MSComCtl2.DTPicker DTPicker2 
         Height          =   375
         Left            =   3480
         TabIndex        =   59
         Top             =   600
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   661
         _Version        =   393216
         Format          =   20643841
         CurrentDate     =   40047
      End
      Begin MSComCtl2.DTPicker DTPicker1 
         Height          =   375
         Left            =   240
         TabIndex        =   58
         Top             =   600
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   661
         _Version        =   393216
         Format          =   20643841
         CurrentDate     =   40047
      End
      Begin VB.Label Label27 
         Caption         =   "Ending Date"
         Height          =   375
         Left            =   3720
         TabIndex        =   62
         Top             =   240
         Width           =   1335
      End
      Begin VB.Label Label15 
         Caption         =   "Starting Date"
         Height          =   375
         Left            =   360
         TabIndex        =   61
         Top             =   240
         Width           =   1455
      End
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   5400
      Top             =   8280
      Width           =   4695
      _ExtentX        =   8281
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.CommandButton btsave 
      Caption         =   "Save"
      Height          =   495
      Left            =   11040
      TabIndex        =   27
      Top             =   7680
      Width           =   975
   End
   Begin VB.Frame Frame3 
      Caption         =   "Agent Details"
      Height          =   6855
      Left            =   7560
      TabIndex        =   29
      Top             =   480
      Width           =   5775
      Begin VB.TextBox txtcode 
         Height          =   375
         Left            =   1320
         TabIndex        =   16
         Top             =   360
         Width           =   1335
      End
      Begin VB.TextBox txtintro 
         Height          =   375
         Left            =   3840
         TabIndex        =   17
         Top             =   360
         Width           =   1335
      End
      Begin VB.TextBox txtunit 
         Height          =   375
         Left            =   1320
         TabIndex        =   18
         Top             =   1512
         Width           =   1335
      End
      Begin VB.TextBox txtagent 
         Height          =   375
         Left            =   3840
         TabIndex        =   19
         Top             =   1512
         Width           =   1335
      End
      Begin VB.TextBox txtdepman 
         Height          =   375
         Left            =   1320
         TabIndex        =   20
         Top             =   2664
         Width           =   1335
      End
      Begin VB.TextBox txtarea 
         Height          =   375
         Left            =   3840
         TabIndex        =   21
         Top             =   2664
         Width           =   1335
      End
      Begin VB.TextBox txtregman 
         Height          =   375
         Left            =   1320
         TabIndex        =   22
         Top             =   3816
         Width           =   1335
      End
      Begin VB.TextBox txtdepadv 
         Height          =   375
         Left            =   3840
         TabIndex        =   23
         Top             =   3816
         Width           =   1335
      End
      Begin VB.TextBox txtdepadv1 
         Height          =   375
         Left            =   1320
         TabIndex        =   24
         Top             =   4968
         Width           =   1335
      End
      Begin VB.TextBox txtdepadv2 
         Height          =   375
         Left            =   3840
         TabIndex        =   28
         Top             =   4968
         Width           =   1335
      End
      Begin VB.TextBox txtdepadv3 
         Height          =   375
         Left            =   1320
         TabIndex        =   25
         Top             =   6120
         Width           =   1335
      End
      Begin VB.TextBox txtchf 
         Height          =   375
         Left            =   3840
         TabIndex        =   26
         Top             =   6120
         Width           =   1335
      End
      Begin VB.Label Label14 
         Caption         =   "Code"
         Height          =   495
         Left            =   240
         TabIndex        =   56
         Top             =   360
         Width           =   855
      End
      Begin VB.Label Label16 
         Caption         =   "Introducer"
         Height          =   375
         Left            =   2880
         TabIndex        =   55
         Top             =   360
         Width           =   735
      End
      Begin VB.Label Label17 
         Caption         =   "Unit"
         Height          =   375
         Left            =   240
         TabIndex        =   54
         Top             =   1512
         Width           =   855
      End
      Begin VB.Label Label18 
         Caption         =   "Agent"
         Height          =   495
         Left            =   2880
         TabIndex        =   53
         Top             =   1392
         Width           =   975
      End
      Begin VB.Label Label19 
         Caption         =   "Dep. Manager"
         Height          =   495
         Left            =   240
         TabIndex        =   52
         Top             =   2544
         Width           =   855
      End
      Begin VB.Label Label20 
         Caption         =   "Area Dev. Manager"
         Height          =   495
         Left            =   2880
         TabIndex        =   51
         Top             =   2544
         Width           =   855
      End
      Begin VB.Label Label21 
         Caption         =   "Reg. Dev. Manager"
         Height          =   615
         Left            =   240
         TabIndex        =   50
         Top             =   3696
         Width           =   735
      End
      Begin VB.Label Label22 
         Caption         =   "Dep. Advisor"
         Height          =   615
         Left            =   2880
         TabIndex        =   49
         Top             =   3696
         Width           =   735
      End
      Begin VB.Label Label23 
         Caption         =   "Dep. Advisor I"
         Height          =   495
         Left            =   240
         TabIndex        =   48
         Top             =   4968
         Width           =   615
      End
      Begin VB.Label Label24 
         Caption         =   "Dep. Advisor II"
         Height          =   495
         Left            =   2880
         TabIndex        =   47
         Top             =   4968
         Width           =   735
      End
      Begin VB.Label Label25 
         Caption         =   "Dep. Advisor III"
         Height          =   375
         Left            =   240
         TabIndex        =   46
         Top             =   6120
         Width           =   855
      End
      Begin VB.Label Label26 
         Caption         =   "Chief Executive"
         Height          =   375
         Left            =   2880
         TabIndex        =   45
         Top             =   6120
         Width           =   975
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Customer Details"
      Height          =   4095
      Left            =   120
      TabIndex        =   31
      Top             =   3240
      Width           =   7215
      Begin RichTextLib.RichTextBox txtaddress 
         Height          =   1335
         Left            =   1440
         TabIndex        =   15
         Top             =   2520
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   2355
         _Version        =   393217
         Enabled         =   -1  'True
         TextRTF         =   $"Form1.frx":0000
      End
      Begin VB.TextBox txtnrelation 
         Height          =   375
         Left            =   6000
         TabIndex        =   14
         Top             =   1920
         Width           =   975
      End
      Begin VB.TextBox txtnage 
         Height          =   375
         Left            =   5400
         TabIndex        =   13
         Top             =   1920
         Width           =   375
      End
      Begin VB.TextBox txtnname 
         Height          =   375
         Left            =   1440
         TabIndex        =   12
         Top             =   1920
         Width           =   1695
      End
      Begin VB.OptionButton Option2 
         Caption         =   "Female"
         Height          =   375
         Left            =   2400
         TabIndex        =   10
         Top             =   1200
         Width           =   855
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Male"
         Height          =   375
         Left            =   1440
         TabIndex        =   9
         Top             =   1200
         Width           =   855
      End
      Begin VB.TextBox txtrname 
         Height          =   375
         Left            =   5400
         TabIndex        =   11
         Top             =   1200
         Width           =   1575
      End
      Begin VB.TextBox txtage 
         Height          =   375
         Left            =   5400
         TabIndex        =   8
         Top             =   480
         Width           =   1575
      End
      Begin VB.TextBox txtname 
         Height          =   375
         Left            =   1440
         TabIndex        =   7
         Top             =   480
         Width           =   1575
      End
      Begin VB.Label Label13 
         Caption         =   "Address"
         Height          =   375
         Left            =   120
         TabIndex        =   44
         Top             =   2640
         Width           =   735
      End
      Begin VB.Label Label12 
         Caption         =   "Age and Relationship"
         Height          =   495
         Left            =   3840
         TabIndex        =   43
         Top             =   2040
         Width           =   1215
      End
      Begin VB.Label Label11 
         Caption         =   "Nominee's Name"
         Height          =   375
         Left            =   120
         TabIndex        =   42
         Top             =   1920
         Width           =   735
      End
      Begin VB.Label Label10 
         Caption         =   "Father's/Husband's Name"
         Height          =   615
         Left            =   3840
         TabIndex        =   41
         Top             =   1200
         Width           =   1455
      End
      Begin VB.Label Label9 
         Caption         =   "Gender"
         Height          =   375
         Left            =   120
         TabIndex        =   40
         Top             =   1200
         Width           =   735
      End
      Begin VB.Label Label8 
         Caption         =   "Age"
         Height          =   255
         Left            =   3840
         TabIndex        =   39
         Top             =   480
         Width           =   1215
      End
      Begin VB.Label Label7 
         Caption         =   "Name"
         Height          =   375
         Left            =   120
         TabIndex        =   38
         Top             =   480
         Width           =   735
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Plan Details"
      Height          =   2535
      Left            =   120
      TabIndex        =   30
      Top             =   480
      Width           =   7215
      Begin MSComCtl2.DTPicker txtdate 
         Height          =   375
         Left            =   4920
         TabIndex        =   1
         Top             =   480
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   661
         _Version        =   393216
         Format          =   20643841
         CurrentDate     =   40046
      End
      Begin VB.ComboBox cbterm 
         Height          =   315
         Left            =   4920
         TabIndex        =   3
         Top             =   1080
         Width           =   1455
      End
      Begin VB.ComboBox cbcost 
         Height          =   315
         Left            =   6000
         TabIndex        =   6
         Top             =   1800
         Width           =   1095
      End
      Begin VB.ComboBox cbinst 
         Height          =   315
         Left            =   4920
         TabIndex        =   5
         Top             =   1800
         Width           =   975
      End
      Begin VB.ComboBox cbmode 
         Height          =   315
         Left            =   1440
         TabIndex        =   4
         Top             =   1800
         Width           =   1575
      End
      Begin VB.ComboBox cbplan 
         Height          =   315
         Left            =   1440
         TabIndex        =   2
         Top             =   1080
         Width           =   1575
      End
      Begin VB.TextBox txtregno 
         Height          =   375
         Left            =   1440
         TabIndex        =   0
         Top             =   360
         Width           =   1575
      End
      Begin VB.Label Label6 
         Caption         =   "Installment and Cost"
         Height          =   375
         Left            =   3360
         TabIndex        =   37
         Top             =   1800
         Width           =   855
      End
      Begin VB.Label Label5 
         Caption         =   "Mode of Payment"
         Height          =   495
         Left            =   120
         TabIndex        =   36
         Top             =   1800
         Width           =   975
      End
      Begin VB.Label Label4 
         Caption         =   "Term"
         Height          =   375
         Left            =   3360
         TabIndex        =   35
         Top             =   1080
         Width           =   855
      End
      Begin VB.Label Label3 
         Caption         =   "Plan No."
         Height          =   255
         Left            =   120
         TabIndex        =   34
         Top             =   1080
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "Date Of Commencement"
         Height          =   375
         Left            =   3360
         TabIndex        =   33
         Top             =   480
         Width           =   1215
      End
      Begin VB.Label Label1 
         Caption         =   "CSS.No."
         Height          =   255
         Left            =   120
         TabIndex        =   32
         Top             =   480
         Width           =   975
      End
   End
   Begin VB.PictureBox Picture2 
      Height          =   855
      Left            =   5400
      ScaleHeight     =   795
      ScaleWidth      =   4635
      TabIndex        =   63
      Top             =   7440
      Width           =   4695
      Begin VB.CommandButton btprint 
         Caption         =   "Print"
         Height          =   495
         Left            =   3480
         TabIndex        =   66
         Top             =   120
         Width           =   975
      End
      Begin VB.TextBox sprint 
         Appearance      =   0  'Flat
         Height          =   495
         Left            =   1680
         TabIndex        =   64
         Top             =   120
         Width           =   1455
      End
      Begin VB.Label Label28 
         Caption         =   "Enter the Reg No."
         Height          =   495
         Left            =   120
         TabIndex        =   65
         Top             =   240
         Width           =   1335
      End
   End
End
Attribute VB_Name = "Jeevan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i, j As Integer
Dim s(10), a, b, c As String
Dim db, db1 As Connection
Dim rs, rs1, rs2, rs3 As Recordset
Private Sub btprinting()
Dim j As Variant
Set rs1 = New Recordset
rs1.LockType = adLockOptimistic
rs1.CursorLocation = adUseServer
rs1.CursorType = adOpenKeyset
rs1.Open "Select * from Customer", db
rs1.MoveFirst
While Not rs1.EOF
If (rs1.Fields(1) >= DTPicker1.Value And rs1.Fields(1) <= DTPicker2.Value) Or sprint = rs1.Fields(0) Then
Printer.PaperSize = vbPRPSA4
Printer.Font = "Copperplate Gothic Light"
Printer.FontSize = 11
If rs1.Fields(2) = "PlanD" Then
Set rs2 = New Recordset
rs2.LockType = adLockOptimistic
rs2.CursorLocation = adUseServer
rs2.CursorType = adOpenKeyset
rs2.Open "Select MonConsi from " & rs1.Fields(2), db
Printer.CurrentX = 7700
Printer.CurrentY = 3800
Printer.Print rs2.Fields(0)
rs2.Close
End If
Printer.CurrentX = 1200
Printer.CurrentY = 4300
Printer.Print Space(1); rs1.Fields(0).Name; rs1.Fields(0); Space(12); Switch(rs1.Fields(2) = "PlanA", "Plan-A", rs1.Fields(2) = "PlanB", "Plan-B", rs1.Fields(2) = "PlanC", "Plan-C", rs1.Fields(2) = "PlanD", "Plan-D")
'Printer.Print
Printer.CurrentX = 1270
Printer.Print Format(rs1.Fields(1), "dd/mm/yyyy"); Space(10); rs1.Fields(3); " Yrs."
Printer.CurrentY = 4350
Printer.CurrentX = 4900
Printer.Print rs1.Fields(6); Space(15); rs1.Fields(4); Space(14); rs1.Fields(5)
Printer.Print
Printer.CurrentX = 2000
Printer.Print rs1.Fields(11); Space(5); rs1.Fields(12); Space(1); "Yrs."; Space(5); rs1.Fields(13)
Printer.Print
Printer.CurrentX = 2000
If rs1.Fields(2) = "PlanA" Or rs1.Fields(2) = "PlanC" Then
Printer.Print "On or before "; Day(rs1.Fields(1)); Switch(Day(rs1.Fields(1)) > 10 And Day(rs1.Fields(1)) <= 20, "th", (Day(rs1.Fields(1)) Mod 10) = 1, "st", (Day(rs1.Fields(1)) Mod 10) = 2, "nd", (Day(rs1.Fields(1)) Mod 10) = 3, "rd", (Day(rs1.Fields(1)) Mod 10) > 3, "th", (Day(rs1.Fields(1)) Mod 10) = 0, "th"); " of every"; Space(2); Switch(rs1.Fields(4) = "Mly", "Month", rs1.Fields(4) = "Qly", "3 Months", rs1.Fields(4) = "Hly", "6 Months", rs1.Fields(4) = "Yly", "Year")
End If
Printer.Print
Printer.Print
Printer.CurrentX = 2000
If rs1.Fields(2) <> "PlanB" Then
Set rs2 = New Recordset
rs2.LockType = adLockOptimistic
rs2.CursorLocation = adUseServer
rs2.CursorType = adOpenKeyset
rs2.Open "Select ExpConsi from " & rs1.Fields(2) & " where Consi='" & rs1.Fields(6) & "'", db
Else
a = Switch(rs1.Fields(3) = "2", "Scheme1", rs1.Fields(3) = "4", "Scheme2", rs1.Fields(3) = "6", "Scheme3")
Set rs2 = New Recordset
rs2.LockType = adLockOptimistic
rs2.CursorLocation = adUseServer
rs2.CursorType = adOpenKeyset
b = rs1!Amt
rs2.Open "Select " & a & " from " & rs1.Fields(2) & " where Consi='" & b & "'", db
End If
Printer.Print rs1.Fields(7);
Printer.Print
Call address(rs1.Fields(14))
For Each j In s
Printer.CurrentX = 2000
Printer.Print j
Next j
Printer.CurrentY = 5900
Printer.CurrentX = 6800
Printer.Print rs2.Fields(0)
Printer.Print
Printer.CurrentX = 6800
If rs1.Fields(2) = "PlanA" Or rs1.Fields(2) = "PlanC" Then
Printer.Print Format(lastdue(), "dd/mm/yyyy")
End If
Printer.CurrentY = 6850
Printer.CurrentX = 6800
Printer.Print Format(expiry(), "dd/mm/yyyy")
Printer.CurrentY = 7200
Printer.CurrentX = 6800
Printer.Print rs1!DistributorCode
Printer.Print vbNewLine
Printer.CurrentY = 8100
Printer.CurrentX = 2800
Printer.FontSize = 9
If rs1.Fields(2) <> "PlanB" Then
Printer.Print convert(Val(rs2!ExpConsi)) + "Only"
Else
Printer.Print convert(Val(rs2.Fields(0))) + "Only"
End If
Printer.CurrentX = 1050
Printer.CurrentY = 9300
Printer.FontSize = 11
Printer.Print Format(Now, "dd/mm/yyyy")
Printer.CurrentY = 11500
Printer.CurrentX = 9000
Printer.Print "Madurai"
Printer.CurrentX = 9000
Printer.Print "0452"
Printer.CurrentX = 9000
Printer.Print rs1.Fields(17)
Printer.CurrentX = 9000
Printer.Print rs1.Fields(16)
Printer.CurrentY = 13300
Printer.CurrentX = 1500
Printer.Print rs1.Fields(7); Space(30); rs1.Fields(8); " Yrs."
Call address(rs1.Fields(14))
For Each j In s
Printer.CurrentX = 1500
Printer.Print j
Next j
Printer.CurrentY = 12800 + 50
Printer.CurrentX = 9000
Printer.Print rs1.Fields(0)
Printer.CurrentY = 13050 + 50
Printer.CurrentX = 9000
Printer.Print Format(rs1.Fields(1), "dd/mm/yyyy")
Printer.CurrentY = 13300 + 50
Printer.CurrentX = 9000
Printer.Print Switch(rs1.Fields(2) = "PlanA", "Plan-A", rs1.Fields(2) = "PlanB", "Plan-B", rs1.Fields(2) = "PlanC", "Plan-C", rs1.Fields(2) = "PlanD", "Plan-D"); " & "; rs1.Fields(3); " Yrs."
Printer.CurrentY = 13550 + 100
Printer.CurrentX = 9000
Printer.Print rs1.Fields(6)
Printer.CurrentY = 13800 + 100
Printer.CurrentX = 9000
Printer.Print rs1.Fields(5)
Printer.CurrentY = 14050 + 100
Printer.CurrentX = 9000
Printer.Print Day(rs1.Fields(1)) & "/" & Format(rs1.Fields(1) + 30, "mm/yyyy")
Printer.CurrentY = 14300 + 150
Printer.CurrentX = 9000
Printer.Print Format(expiry(), "dd/mm/yyyy")
Printer.CurrentY = 14550 + 150
Printer.CurrentX = 9000
Printer.Print rs1.Fields(15)
Printer.CurrentY = 15000 + 150
Printer.CurrentX = 1500
Printer.FontSize = 9
If rs1.Fields(2) = "PlanA" Or rs1.Fields(2) = "PlanC" Then
Printer.Print convert(Val(rs1.Fields(5))) & "Only"
End If
Printer.Print
Printer.CurrentX = 1500
'Printer.FontSize = 11
Printer.Print distributor()
Printer.EndDoc
End If
rs1.MoveNext
Wend
End Sub

Private Sub btprint_Click()
Call btprinting
btprint.Enabled = False
sprint = ""
End Sub

Private Sub btsave_Click()
Set rs1 = New Recordset
rs1.LockType = adLockOptimistic
rs1.CursorLocation = adUseServer
rs1.CursorType = adOpenKeyset
rs1.Open "Select * from Customer", db
If Not rs1.BOF Then
rs1.MoveLast
b = rs1.Fields(0)
c = rs1!Reciept
End If
Set rs2 = New Recordset
rs2.LockType = adLockOptimistic
rs2.CursorLocation = adUseServer
rs2.CursorType = adOpenKeyset
rs2.Open "Select * from Agent", db
If Not rs1.BOF Then
rs1.MoveFirst
While Not rs1.EOF
If txtregno.Text = rs1.Fields(0) Then
MsgBox "Record Already Present"
GoTo l
End If
rs1.MoveNext
Wend
End If
If txtregno.Text = "" Or txtdate.Value = "" Or cbplan.Text = "--Select Plan--" Or cbterm.Text = "--Select Term--" Or cbmode.Text = "--Select Mode--" Or (cbinst.Text = "" And (cbplan.Text = "PlanA" Or cbplan.Text = "PlanC")) Or cbcost.Text = "" Or txtname.Text = "" Or txtage.Text = "" Or txtrname.Text = "" Or txtnname.Text = "" Or txtnrelation.Text = "" Or txtaddress.Text = "" Or txtnage.Text = "" Or txtcode.Text = "" Or txtintro.Text = "" Or txtunit.Text = "" Then
MsgBox "Fill All Fields"
Else
rs1.AddNew
rs1.Fields(0) = updation()
rs1.Fields(1) = txtdate.Value
rs1.Fields(2) = cbplan.Text
rs1.Fields(3) = cbterm.Text & Yrs
rs1.Fields(4) = cbmode.Text
rs1.Fields(5) = cbinst.Text
rs1.Fields(6) = cbcost.Text
rs1.Fields(7) = txtname.Text
rs1.Fields(8) = txtage.Text
rs1.Fields(9) = Switch(Option1, "MALE", Option2, "FEMALE")
rs1.Fields(10) = txtrname.Text
rs1.Fields(11) = txtnname.Text
rs1.Fields(12) = txtnage.Text
rs1.Fields(13) = txtnrelation.Text
rs1.Fields(14) = txtaddress.Text
rs1.Fields(15) = txtcode.Text
rs1.Fields(16) = txtregno.Text
rs1.Fields(17) = updation1()
End If
If txtregno.Text <> "" And txtcode.Text <> "" And txtintro.Text <> "" And txtunit.Text <> "" Then
rs2.AddNew
rs2.Fields(0) = updation()
rs2.Fields(1) = txtcode.Text
rs2.Fields(2) = txtintro.Text
rs2.Fields(3) = txtunit.Text
rs2.Fields(4) = txtagent.Text
rs2.Fields(5) = txtdepman.Text
rs2.Fields(6) = txtarea.Text
rs2.Fields(7) = txtregman.Text
rs2.Fields(8) = txtdepadv.Text
rs2.Fields(9) = txtdepadv1.Text
rs2.Fields(10) = txtdepadv2.Text
rs2.Fields(11) = txtdepadv3.Text
rs2.Fields(12) = txtchf.Text
rs1.Update
rs2.Update
End If
MsgBox "Record Updated"
l:
rs1.Close
rs2.Close
Call clearing
End Sub

Private Sub cbinst_Click()
rs.MoveFirst
cbcost.Clear
While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
If cbmode.Text = rs.Fields(i).Name And cbinst.Text = rs.Fields(i) Then
cbcost.AddItem (rs!Consi)
End If
Next
rs.MoveNext
Wend
End Sub
Private Sub cbmode_Click()
Set rs = New Recordset
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseServer
rs.CursorType = adOpenKeyset
rs.Open "Select * from " & cbplan.Text, db
rs.MoveFirst
cbinst.Clear
For i = 0 To rs.Fields.Count - 1
If cbmode.Text = rs.Fields(i).Name Then
While Not rs.EOF
cbinst.AddItem (rs.Fields(i))
rs.MoveNext
cbinst.Enabled = True
Wend
End If
Next
If cbmode.Text = "Lump Sum" Then
rs.MoveFirst
cbinst.Enabled = False
cbcost.Clear
While Not rs.EOF
cbcost.AddItem (rs!Consi)
rs.MoveNext
Wend
End If
End Sub
Private Sub cbplan_Click()
cbterm.Clear
cbterm.Text = "--Select Term--"
If cbplan.Text = "PlanA" Then
cbterm.AddItem ("2.5")
ElseIf cbplan.Text = "PlanB" Then
cbterm.AddItem ("2")
cbterm.AddItem ("4")
cbterm.AddItem ("6")
Else
cbterm.AddItem ("5")
End If
cbmode.Clear
cbmode.Text = "--Select Mode--"
If cbplan.Text = "PlanA" Or cbplan.Text = "PlanC" Then
cbmode.AddItem ("Mly")
cbmode.AddItem ("Qly")
cbmode.AddItem ("Hly")
cbmode.AddItem ("Yly")
Else
cbmode.AddItem ("Lump Sum")
End If
End Sub

Private Sub Command1_Click()
Call btprinting
DTPicker1.Value = Now
DTPicker1.Value = Now
Command1.Enabled = False
End Sub

Private Sub DTPicker1_Change()
Command1.Enabled = True
End Sub

Private Sub Form_Load()
Adodc1.Visible = False
btsave.Enabled = False
'btprint.Enabled = False
Set db = New Connection
db.Provider = "Microsoft.Jet.OLEDB.4.0"
db.Open App.Path & "\Jeevan.mdb"
cbplan.Clear
cbterm.Text = "--Select Term--"
cbplan.Text = "--Select Plan--"
cbmode.Text = "--Select Mode--"
cbplan.AddItem ("PlanA")
cbplan.AddItem ("PlanB")
cbplan.AddItem ("PlanC")
cbplan.AddItem ("PlanD")
End Sub

Private Sub sprint_Change()
btprint.Enabled = True
End Sub

Private Sub txtunit_LostFocus()
If txtunit.Text <> "" Then
btsave.Enabled = True
btprint.Enabled = True
End If
End Sub
Private Function address(X As String)
j = 0
s(0) = ""
For i = 1 To Len(X)
If AscW(Mid(X, i, 1)) <> 13 Then
s(j) = s(j) + Mid(X, i, 1)
Else
j = j + 1
s(j) = ""
i = i + 1
End If
Next i
End Function
Private Function printword(n As Long, ch As String) As String
Dim one() As String
Dim ten() As String
Dim s As String
ReDim one(20)
one(0) = ""
one(1) = "One"
one(2) = "Two"
one(3) = "Three"
one(4) = "Four"
one(5) = "Five"
one(6) = "Six"
one(7) = "Seven"
one(8) = "Eight"
one(9) = "Nine"
one(10) = "Ten"
one(11) = "Eleven"
one(12) = "Twelve"
one(13) = "Thirteen"
one(14) = "Fourteen"
one(15) = "Fifteen"
one(16) = "Sixteen"
one(17) = "Seventeen"
one(18) = "Eighteen"
one(19) = "Nineteen"
ReDim ten(10)
ten(0) = ""
ten(1) = "Twenty"
ten(2) = "Thirty"
ten(3) = "Fourty"
ten(4) = "Fifty"
ten(5) = "Sixty"
ten(6) = "Seventy"
ten(7) = "Eighty"
ten(8) = "Ninety"
If n <> 0 Then
If n > 19 Then
s = ten(Int(n / 10) - 1) + " " + one(n Mod 10) + ch
Else
s = one(n) + ch
End If
End If
printword = s + " "
End Function
Private Function convert(X As Long) As String
Dim s As String
s = " "
s = printword(Int(X / 10000000), " Crore") + printword(Int(Int(X / 100000) Mod 100), " Lakh") + printword(Int(Int((X / 1000)) Mod 100), " Thousand") + printword(Int(Int(X Mod 1000) / 100), " Hundred") + printword(Int(X Mod 100), " ")
convert = s
End Function
Private Function lastdue() As Date
Dim d As Date
If rs1.Fields(2) = "PlanA" Then
lastdue = Day(rs1.Fields(1)) & "/" & Format(rs1.Fields(1) + (912.5 - 30), "mm/yyyy")
ElseIf rs1.Fields(2) = "PlanC" Then
d = Day(rs1!Date) & "/" & Month(rs1!Date) & "/" & (Year(rs1!Date) + Val(rs1.Fields(3)))
lastdue = Day(rs1!Date) & "/" & Format(d - 30, "mm/yyyy")
End If
End Function
Private Function expiry() As Date
If rs1.Fields(2) = "PlanA" Then
expiry = Day(rs1.Fields(1)) & "/" & Format(rs1.Fields(1) + 912.5, "mm/yyyy")
Else
expiry = Day(rs1!Date) & "/" & Month(rs1!Date) & "/" & (Year(rs1!Date) + Val(rs1.Fields(3)))
End If
End Function
Private Function updation() As String
Dim k As Long
If rs1.BOF Then
k = 10001
Else
k = Val(b) + 1
End If
updation = k
End Function
Private Function updation1() As String
Dim l As Integer
If rs1.BOF Then
l = 1
Else
l = Val(c) + 1
End If
updation1 = l
End Function
Private Function distributor() As String
Set rs3 = New Recordset
rs3.LockType = adLockOptimistic
rs3.CursorLocation = adUseServer
rs3.CursorType = adOpenKeyset
rs3.Open "Select * from Agent", db
i = 1
j = 4
a = ""
rs3.MoveFirst
While Not rs3.EOF
If rs1.Fields(0) = rs3.Fields(0) Then
While j < rs3.Fields().Count
If rs3.Fields(j) <> "" Then
a = a & rs3.Fields(j) & "(" & i & ")" & "  "
End If
i = i + 1
j = j + 1
Wend
End If
rs3.MoveNext
Wend
distributor = a
End Function
Private Sub clearing()
txtregno.Text = ""
txtdate.Value = Now()
cbplan.Text = "--Select Plan--"
cbterm.Text = "--Select Term--"
cbmode.Text = "--Select Mode of Pay--"
cbinst.Text = "--Due--"
cbcost.Text = "--Consi--"
txtname.Text = ""
txtage.Text = ""
Option1.Value = False
Option2.Value = False
txtrname.Text = ""
txtnname.Text = ""
txtnage.Text = ""
txtnrelation.Text = ""
txtaddress.Text = ""
txtcode.Text = ""
txtintro.Text = ""
txtunit.Text = ""
txtagent.Text = ""
txtdepman.Text = ""
txtarea.Text = ""
txtregman.Text = ""
txtdepadv.Text = ""
txtdepadv1.Text = ""
txtdepadv2.Text = ""
txtdepadv3.Text = ""
txtchf.Text = ""
btsave.Enabled = False
'btprint.Enabled = False
txtregno.SetFocus
End Sub
